<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>This test ensures that the focus ring is not shown on the anchor after blurring and focusing the window.</p>
<p><svg width="500" height="30"><a id="anchor" xlink:href="javascript:log('anchor was clicked')"><text font-size="18px" y="20">Anchor</text></a></svg></p>
<pre id="console">
</pre>

<script>
// This test differs from click-anchor-refocus-window.html in two ways:
// 1. getBoundingClientRect().top/left is used instead of .offsetLeft/Top,
//    because offsetLeft is relative to the <svg> element.
// 2. document.activeElement is checked instead of using anchor.onfocus/onblur,
//    because the presence of focus events causes a focus ring to be shown on
//    the SVG anchor (https://crbug.com/445798).
var anchor = document.getElementById('anchor');
window.onfocus = function() {
    log('window was focused');
};
window.onblur = function() {
    log('window was blurred');
};
window.onload = function() {
    if (window.eventSender) {
        // Click the link.
        var anchorRect = anchor.getBoundingClientRect();
        eventSender.mouseMoveTo(anchorRect.left + 2, anchorRect.top + 2);
        eventSender.mouseDown();
        eventSender.mouseUp();
        log('activeElement is ' + (document.activeElement == anchor ? 'anchor' : document.activeElement));
        internals.setFocused(false);
        internals.setFocused(true);
        log('activeElement is ' + (document.activeElement == anchor ? 'anchor' : document.activeElement));
    }
};

function log(message) {
    var console = document.getElementById("console");
    console.textContent += message + '\n';
}
</script>
</body>
</html>
